<template>
    <div class="forum-list-wrap">

        <template v-if="list.length > 0">

            <div class="list">
                <KnowItem v-for="(item, index) in list" :item="item" :key="index"></KnowItem>
            </div>
            <div class="pagination">
                <el-pagination background layout="prev, pager, next" :total="total" @current-change="paginationFun">
                </el-pagination>
            </div>
        </template>
        <el-empty v-else description="没有找到数据"></el-empty>
    </div>
</template>

<script>
import KnowItem from "../pageComponents/know-item.vue";

import {getArticleList} from "@/api/know";
export default {
    components: {
        KnowItem,
    },
    props:{
        keyword:{
            type:String,
            default:''
        }
    },
    data() {
        return {
            params:{
                page:1,
                limit:10,
                type_id:''
            },
            list:[],
            total:0
        };
    },
    mounted() {

        this.getListFun()
    },
    methods: {

        paginationFun(page){
            this.params.page = page
            this.getListFun()
        },
        getListFun(){
            getArticleList({...this.params,keyword:this.keyword}).then(res => {
                if(res.code == 200){
                    this.list = res.data.list || []
                    this.total = res.data.count || 0
                }
            })
        }
    },
};
</script>

<style lang="less" scoped>
.forum-list-wrap {

    .list {
        padding-top: 0.5rem;
    }
    .pagination {
        display: flex;
        justify-content: center;
        padding: 0.375rem 0 1rem;
    }
}
</style>